<template>
  <div class="phoneBox">
    <el-form
      :model="ruleForm"
      status-icon
      :rules="rules"
      ref="ruleForm"
      label-width="100px"
      class="demo-ruleForm"
    >
      <el-form-item prop="phone" style="width: 450px">
        <el-input
          type="txt"
          v-model="ruleForm.phone"
          autocomplete="off"
          placeholder=" 请输入你的手机号"
          style="margin-left: -100px; margin-top: 15px"
          ><span slot="prefix">+86</span></el-input
        >
      </el-form-item>
      <el-form-item style="margin-left: -100px">
        <el-button
          style="width: 350px"
          type="primary"
          @click="submitForm('ruleForm')"
          >下一步</el-button
        >
      </el-form-item>
    </el-form>
    <div style="font-size: 12px; display: flex; line-height: 10px">
      <el-checkbox v-model="checked"></el-checkbox>
      <div style="margin-top: 2px; margin-left: 5px">
        我已阅读并同意 <span style="color: #409eff">服务协议</span> 和
        <span style="color: #409eff">隐私协议</span>
      </div>
    </div>
    <div class="more">
      <div class="left_H"></div>
      <div class="middle_txt">更多登录方式</div>
      <div class="right_H"></div>
    </div>
    <div style="margin-top: 17px">
      <el-button
        size="medium"
        round
        style="width: 350px; color: black"
        icon="el-icon-refresh"
        >其他登录方式</el-button
      >
    </div>
  </div>
</template>
<script>
export default {
  name: "LoginPhone",
  data() {
    const validatePhone = (rule, value, callback) => {
      if (!value) {
        return callback(new Error("请输入手机号"));
      } else if (!/^1[3-9]\d{9}$/.test(value)) {
        return callback(new Error("手机号格式不正确"));
      } else {
        callback();
      }
    };
    return {
      ruleForm: {
        phone: "",
      },
      rules: {
        phone: [{ validator: validatePhone, trigger: "blur" }],
      },
      checked: true,
    };
  },
  mounted() {},
  methods: {
    submitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          alert("submit!");
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
  },
};
</script>
<style lang='scss' scoped>
.phoneBox {
  width: 350px;
  height: 350px;
  .more {
    width: 350px;
    height: 20px;
    margin-top: 130px;
    display: flex;
    justify-content: space-between;
    .left_H {
      width: 125px;
      height: 1px;
      background: #dcdfe6;
      margin-top: 10px;
    }
    .middle_txt {
      width: 100px;
      height: 20px;
      color: #909399;
      text-align: center;
      line-height: 20px;
      font-size: 10px;
    }
    .right_H {
      width: 125px;
      height: 1px;
      background: #dcdfe6;
      margin-top: 10px;
    }
  }
}
</style>